package com.hu.config.comment;

public class ResponseResult<T> {
    private static final int SUCCESS = 200;//成功
    private static final int FAIL = 400;//失败
    private static final int UNAUTHORIZED = 401;//未认证（签名错误）
    public static final int NOT_FOUND = 404;//找不到资源，如文件，url
    public static final int ERROR = 500;//服务器内部错误

    private int status;
    private String message;
    private Object data;

    public ResponseResult(int status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static ResponseResult success(String message) {
     return new ResponseResult(SUCCESS,message,null);
    }
    public static ResponseResult success(String message, Object data) {
        return new ResponseResult(SUCCESS,message,data);
    }
    public static ResponseResult fail(String message) {
        return new ResponseResult(FAIL,message,null);
    }
    public static ResponseResult unauthorized(String message) {
        return new ResponseResult(UNAUTHORIZED,message,null);
    }
    public static ResponseResult notFound(String message) {
        return new ResponseResult(NOT_FOUND,message,null);
    }
    public static ResponseResult error(String message) {
        return new ResponseResult(ERROR,message,null);
    }
}
